package datastruct.stack;

import java.util.LinkedList;

/**
 * @author RunningShrimp
 * @date 2021/5/9  17:44
 */
public class LinkedStack<E> implements Stack<E> {

    private final LinkedList<E> lineList;

    public LinkedStack() {
        this.lineList = new LinkedList<>();
    }

    @Override
    public void push(E e) {
        lineList.addLast(e);
    }

    @Override
    public E pop() {
        return lineList.removeLast();
    }

    @Override
    public E peek() {
        return lineList.getLast();
    }

    @Override
    public int size() {
        return lineList.size();
    }

    @Override
    public boolean empty() {
        return lineList.isEmpty();
    }
}
